package jm.nj.day10.demo03;

import java.io.*;

/*
* bw.newtLine;根据平台 自动写入一个换行
* br.readLine;一次读取一行,不读取换行符,读取完毕 返回null
*
* */
public class Test03 {
    public static void main(String[] args) throws IOException {
        //hello写入bb.txt
        BufferedWriter bw = new BufferedWriter(new FileWriter("bb.txt"));

        bw.write("hello");
        bw.flush();
        bw.newLine();
        bw.write("world");
        bw.close();

        BufferedReader br = new BufferedReader(new FileReader("bb.txt"));

       /* String lin = br.readLine();
        System.out.println(lin);*/

        String line;
        /*
        * 1.br.readLine读取一次数据
        * 2.把读取的数据用line指向
        * 3.判断 line != -1 的真假
        * */
        while ((line = br.readLine()) != null){
            System.out.println(line);
        }

        br.close();

    }
}
